<html>
<head>
<style type="text/css">
.style50 {
	color: #FFFFFF;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
	font-size: 24px;
}
.style53 {color: #ECE9D8}
.style54 {
	color: #0000CC;
	font-weight: bold;
}
.style55 {
	color: #0000FF;
	font-weight: bold;
}
.style56 {color: #0000FF}
.style57 {
	color: #FFFFFF;
	font-weight: bold;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<form action="hoadonn.php"  method="post" enctype="multipart/form-data" name="form1" class="style53">
   <table width="540" height="400" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr align="center" bgcolor="#0066FF">
      <td colspan="2" class="style50">HÓA ĐƠN NHẬP</td>
    </tr>
    <tr align="center" bgcolor="#0066FF">
      <td colspan="2" bgcolor="#FFFFFF" class="style50">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td width="155" bgcolor="#FFFFFF"><span class="style55">Mã hóa đơn nhập</span> </td>
      <td width="385" bgcolor="#FFFFFF"><input name="mahdn" type="text" value="<?php echo $_POST["mahdn"]; ?>" size="40"></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td colspan="2" bgcolor="#FFFFFF"><span class="style55">Mã nhà cung cấp </span><font size="3" face="Times New Roman, Times, serif">
        <input name="mancc" type="text" value="<?php echo $_POST["mancc"]; ?>" size="20">
        <span class="style55">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tên nhà CC   </span>
        &nbsp;&nbsp;<input name="tenncc" type="text" value="<?php echo $_POST["tenncc"]; ?>" size="30">
      </font></td>
	  
    </tr>
	<tr bgcolor="#FFCCCC">
      <td colspan="2" bgcolor="#FFFFFF"><span class="style55">Địa chỉ nhà cung cấp </span><font size="3" face="Times New Roman, Times, serif">
        <input name="diachi" type="text" value="<?php echo $_POST["diachi"]; ?>" size="20">
        <span class="style55">&nbsp;&nbsp;&nbsp;&nbsp;</span>      </font></td>
	  
    </tr>
	
    <tr bgcolor="#FFCCCC">
      <td colspan="2" bgcolor="#FFFFFF"><span class="style55">Điện thoại </span><span class="style8 style3"><font size="3" face="Times New Roman, Times, serif">
        <span class="style55">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
        <input name="dienthoai" type="text" value="<?php echo $_POST["dienthoai"]; ?>" size="20">
        <span class="style55">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font></span><span class="style55"><font size="3" face="Times New Roman, Times, serif">Tài khoản&nbsp;&nbsp;&nbsp;</font></span><font size="3" face="Times New Roman, Times, serif"><span class="style8 style3"><span class="style55">&nbsp;&nbsp;</span> 
        <input name="sotk" type="text" value="<?php echo $_POST["sotk"]; ?>" size="30">
        </span></font></td>
    </tr>
    
    <tr bgcolor="#FFCCCC">
      <td colspan="2" bgcolor="#FFFFFF"><div align="left"><span class="style54">Mã nhân viên<font size="3" face="Times New Roman, Times, serif"><span class="style55">&nbsp;&nbsp;&nbsp; &nbsp;</span></font> </span><font size="3" face="Times New Roman, Times, serif">
        <select name="manv"  size="1" id="manv">
          <?php
				require("hoadonn.php");
$sql="select * from nv";
$result=mysql_query($sql,$link);
$tongrec= mysql_num_rows($result);
if ($tongrec!=0)
	{
		while ($row=mysql_fetch_array($result))
			{
				$manv=$row["manv"];
				$tennv=$row["tennv"];
				echo "<option value=$manv>$manv-$tennv</option>";		
				mysql_close($link);	
			}
	}
?>
        </select>
      </font> </div></td>
    </tr>
      <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF"><span class="style55">Mã sản phẩm</span></td>
      <td bgcolor="#FFFFFF"><font size="3" face="Times New Roman, Times, serif">
        <input name="mamh" type="text" value="<?php echo $_POST["masp"]; ?>" size="20">
        <span class="style55">Tên sản phẩm </span>
        <input name="tenmh22" type="text" value="<?php echo $_POST["tensp"]; ?>" size="20">
      </font></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF"><span class="style55">Tên sản phẩm </span></td>
      <td bgcolor="#FFFFFF"><input name="tensp" type="text" value="<?php echo $_POST["tensp"]; ?>" size="40"></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF"><span class="style55"><font face="Times New Roman, Times, serif" size="3">Giá nhập </font></span></td>
      <td bgcolor="#FFFFFF"><input name="dongian" type="text" id="dongian" value="<?php echo $_POST["dongian"]; ?>">
      VNĐ</td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Số lượng </td>
      <td bgcolor="#FFFFFF"><input name="soluong" type="text" id="soluong" value="<?php echo $_POST["soluong"];?>"></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Bảo hành </td>
      <td bgcolor="#FFFFFF">      <input name="baohanh" type="text" id="baohanh" value="<?php echo $_POST["baohanh"];?>">
      Tháng</td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Ngày nhập </td>
      <td bgcolor="#FFFFFF"><input name="ngaynhap" type="text" id="ngaynhap" value="<?php echo $_POST["ngaynhap"];?>"></td>
    </tr>
    
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Đặc điểm linh kiện:</td>
      <td bgcolor="#FFFFFF">      <textarea name="ddmh" cols="40" rows="2" id="ddmh" value="<?php echo $_POST["ddmh"];?>"></textarea></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Chi tiết </td>
      <td bgcolor="#FFFFFF">      <textarea name="trangthaimh" cols="40" rows="2" id="trangthaimh"><?php echo $_POST["trangthaimh"]; ?></textarea></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF"><span class="style55"><font face="Times New Roman, Times, serif" size="3">Hiện trang chủ </font></span></td>
      <td bgcolor="#FFFFFF"><font size="3" face="Times New Roman, Times, serif">
        <select name="trangchu"  size="1" id="select">   
	<option>co</option>
	<option>khong</option>
        </select>
      </font></td>
    </tr>
    <tr bgcolor="#FFCCCC">
      <td bgcolor="#FFFFFF" class="style55">Hình ảnh:</td>
      <td bgcolor="#FFFFFF"><input type="file" name="file" value="<?php echo $row['hinh'];?>"></td>
    </tr>
    <tr align="center" bgcolor="#FFCCCC">
      <td colspan="2" bgcolor="#FFFFFF"><p>
        <input name="Submit" type="submit" class="style54" value="Thêm mới">
        <input name="Submit2" type="reset" class="style54" value="Xóa">
      </p>
      <p>
        <?php 
$mamh=$_REQUEST[mamh]; 
$tenmh=$_REQUEST[tenmh]; 
$malh=$_REQUEST[malh];
$gia=$_REQUEST[gia]; 
$soluong=$_REQUEST[soluong]; 
$baohanh=$_REQUEST[baohanh];
$trangthaimh=$_REQUEST[trangthaimh]; 
$ddmh=$_REQUEST[ddmh];
$mancc=$_REQUEST[mancc];
$trangchu=$_REQUEST[trangchu];
$ngaynhap=$_REQUEST[ngaynhap];
$link = mysql_connect ("localhost", "root", "");  
mysql_select_db("xuka", $link);  
 if(!is_numeric($soluong) || !is_numeric($gia))
	{
		echo "Kiểm tra lại thông tin nhập vào.";
		exit;
	}
	if ($_FILES["file"]["error"]>0)
	{
		echo "Error: ".$_FILES["file"]["error"]."<br>";
		exit;
	}
	else
	{
		move_uploaded_file($_FILES["file"]["tmp_name"],"/".$_FILES["file"]["name"]);
$hinh="img/".$_FILES["file"]["name"];
		}
 $result=mysql_query("select * from mahang where mamh='$mamh'");
	$n=0;
	$n=mysql_num_rows($result);
	
	if ($n!=0)
	{
		echo "mã loại hàng này đã có!!! Mời bạn nhập lại";
		}
	else
	{
$sql="insert into mahang(mamh,tenmh,malh,gia,soluong,trangchu,baohanh,mancc,trangthaimh,ddmh,ngaynhap,hinh) value 
('$mamh','$tenmh','$malh','$gia','$soluong','$trangchu','$baohanh','$mancc','$trangthaimh','$ddmh','$ngaynhap','$hinh')"; 
$result=mysql_query($sql,$link);  

}  
echo"<table>";
echo"<tr> <td>";
echo "Mã mặt hàng :".$_REQUEST["mamh"]."<br>";
echo "Mã loại hàng : ".$_REQUEST["malh"]."<br>";
echo "Tên mặt hng: ".$_REQUEST["tenmh"]."<br>";
echo "Giá bán : ".$_REQUEST["gia"]."<br>";
echo "Bảo hành : ".$_REQUEST["baohanh"]."<br>";
echo "Số luợng : ".$_REQUEST["soluong"]."<br>";
echo "Đặc điểm mặt hàng: ".$_REQUEST["ddmh"]."<br>";
echo "Ngày nhập: ".$_REQUEST["ngaynhap"]."<br>";
echo "Chi tiết mặt hàng : ".$_REQUEST["trangthaimh"]."<br>";
echo "<img src='$hinh'>";	
echo"</td></tr>";
?>
        </p></td>
    </tr>
</table>
</form>
</body>
</html>